<?php

namespace Kunfeng\Dify\Model\Common;

/**
 * 简单响应模型
 */
class SimpleResponse
{
    private $result;

    public function __construct(string $result)
    {
        $this->result = $result;
    }

    /**
     * 从数组创建响应
     */
    public static function fromArray(array $data): self
    {
        return new self($data['result'] ?? '');
    }

    /**
     * 转换为数组
     */
    public function toArray(): array
    {
        return ['result' => $this->result];
    }

    /**
     * 判断是否成功
     */
    public function isSuccess(): bool
    {
        return $this->result === 'success';
    }

    /**
     * 获取结果
     */
    public function getResult(): string
    {
        return $this->result;
    }
}